#include<iostream>
using namespace std;
int map[5][5] =
{
0,0,1,1,0,
1,0,0,1,0,
0,1,0,0,1,
0,0,1,0,1,
1,1,0,0,0
};
int arr[210], brr[210];
int n, na, nb;
int ha = -1, hb = -1;
int main()
{
	cin >> n >> na >> nb;
	for (int i = 0; i < na; i++) {
		cin >> arr[i];
	}
	for (int i = 0; i < nb; i++) {
		cin >> brr[i];
	}
	int sumA = 0;
	int sumB = 0;
	for (int i = 0; i < n; i++) {
		ha++;
		hb++;
		ha %= na;
		hb %= nb;
		sumA += map[arr[ha]][brr[hb]];
		sumB += map[brr[hb]][arr[ha]];
	}
	cout << sumA << " " << sumB << " ";
	return 0;
}